Intro to ASM

credit purely goes to pwn.college

This is where I manage my notes since i have a goldfish memory and am a victim of forgetfulness.

1 ] Intro to assembly

x86 intel syntax asm is very easy. You just have to start off with:

.intel_syntax noprefix
.globl _start
_start:
[commands]

noprefix basically says “bruv tu sambhal le size, idgaf”. we store such files with a .S extension. I.e., code.S

To create an object file out of this, we use the command

as code.S -o code.o

once we have the object file, we have to note that code is always stored in the .text section. therefore, we only use the .text section in the object file to create a binary

objcopy -O binary —only-section=.text code.o code.bin

man page for objcopy can be found here.

2] Registers

you may ask why is H8 of rsi/rbp etc not accessible. i don’t know. i trust the manufacturers.

hex 0xfffffff.. is basically all 1’s. hex 0x000.. is basically all 0’s.

3] Memory